/*
 * OrganService.java
 *
 * Copyright 2012 the original author or authors(ninglong).
 *
 * Licensed under the org.geek.organ.service.impl, Version 1.0 (the "License");
 *
 */
package org.geek.organ.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.geek.common.entity.Criteria;
import org.geek.common.entity.Menu;
import org.geek.domain.Organ;
import org.geek.organ.mapper.OrganMapper;
import org.geek.organ.service.IOrganService;
import org.springframework.stereotype.Service;

/**
 * <p></p>
 * @author ninglong bhd2973@qq.com
 * @version V1.0
 */
@Service
public class OrganService implements IOrganService {

	@Resource
	private OrganMapper organMapper;
	
	public List<Menu> getOrgans2Menu (){
		Criteria criteria = new Criteria();
		List<Organ> list = organMapper.getOrganByCriteria(criteria);
		List<Menu> menus = new ArrayList<Menu>();
		for(Organ organ : list){
			Menu menu = new Menu();
			menu.setId(organ.getOrganId());
			menu.setText(organ.getOrganName());
			menu.setName(organ.getOrganName());
			menu.setParentId(organ.getParentId());
			menus.add(menu);
		}
		return menus;
	}

	public int countOrganByCriteria(Criteria criteria) {
		return organMapper.countOrganByCriteria(criteria);
	}

	public List<Organ> getOrganByCriteria(Criteria criteria) {
		return organMapper.getOrganByCriteria(criteria);
	}

	public int modOrgan(Organ organ) {
		return organMapper.modOrgan(organ);
	}

	public int addOrgan(Organ organ) {
		return organMapper.addOrgan(organ);
	}

	public int delOrganByOrganId(int organId) {
		return organMapper.delOrganByOrganId(organId);
	}
}